#!/usr/local/bin/python
# coding=utf-8

import subprocess
import ibm_db_dbi
from sys import platform
from log_module import *

# 数据库的配置
if platform == "linux" or platform == "linux2":
    lines = list(open('/app/webserver/auth11.conf'))
    database = lines[0].rstrip()
    hostname = lines[1].rstrip()
    uid = lines[2].rstrip()
    pwd = lines[3].rstrip()
else:
    database = "UACSDB"
    hostname = "10.0.1.10"
    uid = "uacsapp"
    pwd = "uacsapp"
dsn = "DRIVER = {IBM DB2 ODBC DRIVER}; DATABASE="+ database + ";HOSTNAME="+hostname+";PORT=50000;PROTOCOL=TCPIP;UID="+uid+";PWD="+pwd+";"
dsn_ibm_dbi =  "DRIVER = {IBM DB2 ODBC DRIVER}; DATABASE="+ database + ";HOSTNAME="+hostname+";PORT=50000;PROTOCOL=TCPIP;UID="+uid+";PWD="+pwd+";"

# 连接数据库
conn_ibm_dbi = ibm_db_dbi.connect(dsn_ibm_dbi, "", "")
if conn_ibm_dbi:
    print "connet db2 successful!"

# log 存放路径的配置
if platform == "linux" or platform == "linux2":
    save_logfile_info = "/iPlature/log/logzeroInfo.log"
    save_logfile_debug = "/iPlature/log/logzeroDebug.log"
    save_logfile_error = "/iPlature/log/logzeroError.log"
    save_logfile_warn = "/iPlature/log/logzeroWarn.log"
else:
    save_logfile_info = "D:\\iPlature\\log\\logzeroInfo.log"
    save_logfile_debug = "D:\\iPlature\\log\\logzeroDebug.log"
    save_logfile_error = "D:\\iPlature\\log\\logzeroError.log"
    save_logfile_warn = "D:\\iPlature\\log\\logzeroWarn.log"

# 打印日志输出
infoLogger = log_log(name="info", logfile=""+ save_logfile_info +"", maxBytes=1024 * 1024, backupCount=3)
debugLogger = log_log(name="debug", logfile=""+ save_logfile_debug +"", maxBytes=1024 * 1024, backupCount=3)
errorLogger = log_log(name="error", logfile=""+ save_logfile_error +"", maxBytes=1024 * 1024, backupCount=3)
warnLogger = log_log(name="warn", logfile=""+ save_logfile_warn +"", maxBytes=1024 * 1024, backupCount=3)

# 库图-鞍座定义数据表
STOCK_INFORMATION_DATABASE = 'UACS_YARDMAP_STOCK_DEFINE'

# # 钢卷信息表
COIL_INFORMATION_DATABASE = 'UACS_SCHEDULE_COIL'

# 钢卷外径方向余量
MARGIN_SPACE = 30

# 小尾卷的最大外径
MAX_SMALL_COIL_OUTDIA = 2000

# 波浪形鞍座的Y_START
Y_START = 4405

# 跨号
Bay_02= 'X13'
Bay_04= 'X12'
Bay_05= 'X11'

